﻿using Mathmall.Administration.Models;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace Mathmall.Administration.Data
{
    public class SpuInfoEntityTypeConfiguration : IEntityTypeConfiguration<SpuInfo>
    {
        public void Configure(EntityTypeBuilder<SpuInfo> builder)
        {
            // 不使用output子句
            builder.ToTable(table => table.UseSqlOutputClause(false));

            builder
                .ToTable(nameof(SpuInfo))
                .ToTable(tableBuilder => tableBuilder.HasComment("spu信息"));

            builder
                .HasKey(spuInfo => spuInfo.SpuInfoID)
                .HasName("SpuInfoID");

            builder
                .Property(spuInfo => spuInfo.SpuName)
                .HasColumnName("SpuName")
                .HasColumnType("nvarchar(200)")
                .HasComment("商品名称")
                .IsRequired(false);

            builder
                .Property(spuInfo => spuInfo.SpuDescription)
                .HasColumnName("SpuDescription")
                .HasColumnType("nvarchar(1000)")
                .HasComment("商品描述")
                .IsRequired(false);

            builder
                .Property(spuInfo => spuInfo.CatalogID)
                .HasColumnName("CatalogID")
                .HasColumnType("int")
                .HasComment("所属分类id")
                .IsRequired(false);

            builder
                .Property(spuInfo => spuInfo.BrandID)
                .HasColumnName("BrandID")
                .HasColumnType("int")
                .HasComment("品牌id")
                .IsRequired(false);

            builder
                .Property(spuInfo => spuInfo.Weight)
                .HasColumnName("Weight")
                .HasColumnType("decimal")
                .HasComment("商品重量")
                .IsRequired(false);

            builder
                .Property(spuInfo => spuInfo.PublishStatus)
                .HasColumnName("PublishStatus")
                .HasColumnType("tinyint")
                .HasComment("上架状态[0 - 下架，1 - 上架]")
                .IsRequired(false);

            builder
                .Property(spuInfo => spuInfo.CreateTime)
                .HasColumnName("CreateTime")
                .HasColumnType("datetime")
                .HasComment("创建时间")
                .IsRequired(false);

            builder
                .Property(spuInfo => spuInfo.LastUpdateTime)
                .HasColumnName("LastUpdateTime")
                .HasColumnType("datetime")
                .HasComment("最后更新时间")
                .IsRequired(false);
        }
    }
}
